@extends('admin::layouts.master')

@section('content')
    <div class="col-lg-12">
        <div class="card card-table">
                <div class="card-header">
                    用户管理
                </div>
                <div class="xs-mt-30 xs-mb-20 text-center">
                    <a href="" class="btn btn-space btn-success md-trigger">用户列表</a>
                    <button data-toggle="modal" data-target="#addUser" type="button" class="btn btn-space btn-primary">添加用户</button>
                </div>
                @component('components.modal',['title'=>'添加用户','url'=>'/admin/adminuser','id'=>'addUser'])
                <div class="form-group">
                    <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录账号</font></font></label>
                    <input type="text" name="name" placeholder="请输入登录账号..." class="form-control">
                </div>
                <div class="form-group">
                    <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录昵称</font></font></label>
                    <input type="text" name="nickname" placeholder="请输入用户昵称..." class="form-control">
                </div>
                <div class="form-group">
                    <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录密码</font></font></label>
                    <input type="password" name="password" placeholder="请输入用户密码..." class="form-control">
                </div>
                @endcomponent
                <div class="card-body">

                <table class="table">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>账号</th>
                        <th>昵称</th>
                        <th>创建时间</th>
                        <th class="actions">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($admins as $v)
                        <tr>
                            <td>{{$v['id']}}</td>
                            <td>{{$v['name']}}</td>
                            <td>{{$v['nickname']}}</td>
                            <td>{{$v['created_at']}}</td>
                            <td class="actions">
                                <div class="btn-group btn-space">
                                    <button data-toggle="modal" data-target="#editUser{{$v['id']}}" type="button" class="btn btn-space btn-primary">编辑</button>

                                @component('components.modal',['title'=>'编辑用户','url'=>'/admin/adminuser/'.$v['id'],'id'=>'editUser'. $v['id'],'method'=>'PUT'])
                                        <div class="form-group text-left">
                                            <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录账号</font></font></label>
                                            <input type="text" name="name" value="{{$v['name']}}" class="form-control">
                                        </div>
                                        <div class="form-group text-left">
                                            <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录昵称</font></font></label>
                                            <input type="text" name="nickname" value="{{$v['nickname']}}" placeholder="请输入用户昵称..." class="form-control">
                                        </div>
                                        <div class="form-group text-left">
                                            <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录密码</font></font></label>
                                            <input type="password" name="password" placeholder="请输入用户密码..." class="form-control">
                                        </div>
                                    @endcomponent
                                    <form action="{{route('adminuser.destroy',$v['id'])}}" method="post">
                                        @csrf
                                        @method('delete')
                                        <button type="submit" class="btn btn-danger">删除</button>
                                    </form>
                                    <a href="{{route('showRole',$v['id'])}}" style="height: 30px;" class="btn btn-success ml-1">分配角色</a>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
        {{$admins->links()}}
    </div>
@stop
